/*
 * Function: This class contains all information of each token which appears in code text
 * Author: Ray
 * Version history: 2013.09.01 -> coding start
 */
package main;

public class tokens 
{
	//token
	private String strToken;
	//current state(-2: process failed; -1: abandon; 0: before process; 1: dictionary 2: process succeeded)
	private int intState;
	//occurrence location in code text
	private String strLocation;
	//analysis result
	private String strResult;
	
	/*
	 * Function: Initialize tokens
	 * Input: pToken -> new token
	 * Output: none
	 */
	public tokens(String pToken)
	{
		strToken = pToken;
		intState = 0;
		strLocation = "";
		strResult = "";
	}
	
	/*
	 * Function: Initialize tokens
	 * Input: pToken -> new token
	 * 		  pLoc -> First location
	 * Output: none
	 */
	public tokens(String pToken, String pLoc)
	{
		strToken = pToken;
		intState = 0;
		strLocation = pLoc;
		strResult = "";
	}
	
	/*
	 * Function: Add new location to current token
	 * Input: pLoc -> current occurrence location 
	 * Output: none
	 */
	public void addLocation(String pLoc)
	{
		if (strLocation.equals(""))
		{
			strLocation = strLocation + pLoc;
		}
		else
		{
			strLocation = strLocation + "," + pLoc;
		}
	}
	
	/*
	 * Function: Set token state
	 * Input: pState -> Current state (-2: process failed; -1: abandon; 1: dictionary)
	 * Output: none
	 */
	public void setState(int pState)
	{
		intState = pState;
	}
	
	/*
	 * Function: Set token analysis result and current state
	 * Input: pResult -> analysis result
	 * Output: none
	 */
	public void setResult(String pResult)
	{
		intState = 2;
		strResult = pResult;
	}
	
	/*
	 * Function: Return token
	 * Input: none
	 * Output: token
	 */
	public String getToken()
	{
		return strToken;
	}
	
	/*
	 * Function: Return state
	 * Input: none
	 * Output: state (-2: process failed; -1: abandon; 0: before process; 1: dictionary 2: process succeeded)
	 */
	public int getState()
	{
		return intState;
	}
	
	/*
	 * Function: Return all location
	 * Input: none
	 * Output: All location
	 */
	public String getLocation()
	{
		return strLocation;
	}
	
	/*
	 * Function: Return analysis result
	 * Input: none
	 * Output: Analysis result
	 */
	public String getResult()
	{
		return strResult;
	}
	
	
}
